package co.fitstart.admin.entity.report;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.core.utils.DateFormatUtils;
import com.demo2do.core.utils.DateUtils;

import co.fitstart.entity.site.Site;

public class ReportPrepare {
    
    private Site selectSite;
    
    private Date currentDate;
    
    private String period;
    
    private String startDate;
    
    private String endDate;
    
    private String today;
    
    /**
     * 
     */
    public ReportPrepare() {
        
    }
    
    /**
     * 
     * @param site
     * @param date
     * @param period
     */
    public ReportPrepare(Site site, Date date, String period) {
        this.selectSite = site;
        
        this.currentDate = date == null ? DateUtils.addDays(new Date(), -1) : date;
        this.period = period;
        
        if(StringUtils.equalsIgnoreCase(period, "week")) {
            this.startDate = DateFormatUtils.format(DateUtils.getFirstWeekDay(date), "yyyy-MM-dd");
            this.endDate = DateFormatUtils.format(DateUtils.getLastWeekDay(date), "yyyy-MM-dd");
        } else if (StringUtils.equalsIgnoreCase(period, "month")) {
            this.startDate = DateFormatUtils.format(DateUtils.getFirstMonthDay(date), "yyyy-MM-dd");
            this.endDate = DateFormatUtils.format(DateUtils.getLastMonthDay(date), "yyyy-MM-dd");
        }
        
        this.today = DateFormatUtils.format(DateUtils.addDays(new Date(), -1), "yyyy-MM-dd");
    }
    
    /**
     * 
     * @return
     */
    public Map<String, Object> describeReport() {
        Map<String, Object> result = new HashMap<String, Object>();
        
        result.put("selectSite", this.selectSite);
        result.put("currentDate", this.currentDate);
        result.put("period", this.period);
        result.put("startDate", this.startDate);
        result.put("endDate", this.endDate);
        result.put("today", this.today);
        
        return result;
    }

    /**
     * @return the selectSite
     */
    public Site getSelectSite() {
        return selectSite;
    }

    /**
     * @return the currentDate
     */
    public Date getCurrentDate() {
        return currentDate;
    }

    /**
     * @return the period
     */
    public String getPeriod() {
        return period;
    }

    /**
     * @return the startDate
     */
    public String getStartDate() {
        return startDate;
    }

    /**
     * @return the endDate
     */
    public String getEndDate() {
        return endDate;
    }

    /**
     * @return the today
     */
    public String getToday() {
        return today;
    }

    /**
     * @param selectSite the selectSite to set
     */
    public void setSelectSite(Site selectSite) {
        this.selectSite = selectSite;
    }

    /**
     * @param currentDate the currentDate to set
     */
    public void setCurrentDate(Date currentDate) {
        this.currentDate = currentDate;
    }

    /**
     * @param period the period to set
     */
    public void setPeriod(String period) {
        this.period = period;
    }

    /**
     * @param startDate the startDate to set
     */
    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    /**
     * @param endDate the endDate to set
     */
    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    /**
     * @param today the today to set
     */
    public void setToday(String today) {
        this.today = today;
    }

}
